package org.aileen.springioc.demo.Component;

import org.aileen.springioc.demo.model.UserInfo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

@Component
public class UserComponent {
    public void sayHi(){
        System.out.println("Hi UserComponent...");
    }

    @Bean({"o1","o2"})//对象1
    public UserInfo userInfo(){
        UserInfo user = new UserInfo(1, "Aileen");
        return user;
       //return new UserInfo();
    }
    //@Primary
    @Bean//对2
    public UserInfo userInfo2(){
        return new UserInfo(2,"Kevin");
    }
}
